import React, { Component } from 'react'
import copy from 'copy-to-clipboard';
import * as action  from "../action/index"  // 从这个文件中引入所有抛出的方法并起别名为*
import {bindActionCreators} from "redux" // bindActionCreators 是用来合并抽离出去的dispatch得
import {connect} from "react-redux" // 带花括号的引入得名字必须是我写的这样，不带花括号的引入时随意起名
class App extends Component {
  componentDidMount() {
    this.props.getList()
  }
    checkname () {
        copy("zhangsan")
        this.props.changeName()
    }
  render() {
    console.log(this.props);
    return (
      <div>
          {this.props.name}
          <button onClick={this.checkname.bind(this)}>点击我修改名字</button>
          {
            this.props.arr && this.props.arr.length ?  this.props.arr . map ((item,index)=>{
              return <div key={index}>
                {item.Name}
              </div>
            }):"暂无数据"
          }
      </div>
    )
  }
}
// 快捷键rxm
const mapStateToProps = (state) => {
    console.log(state);
    return {
        ...state.AppReducer
    }
}

const mapDispatchToProps = (dispatch)=> bindActionCreators(action,dispatch)
export default connect(mapStateToProps,mapDispatchToProps)(App)